import { useMemo, useState ,memo} from "react";

// useMemo 对传递进子组件的属性进行优化
// memo 将组件包裹自动的区优化每一项props
//针对props进行优化:优化性能,对比本次数据和上一次是否一致,如果一样,则组建不更新
const app = function (props) {
  console.log(props);
  return <div>我是一个app</div>;
};
// 使用React.memo对函数组件进行优化
// const App = memo(app)
const App = app;
const Parent = function () {
  const [count, setCount] = useState(5);
  const myCount = useMemo(() => {
    return {
      count,
    };
  }, [count]);
  return (
    <div>
      <button onClick={() =>setCount(5)}>++</button>
      <App myCount={myCount}></App>
    </div>
  );
};
export default Parent;
